package com.citcc.web.controller.business;

import com.citcc.business.bean.CdzAmountDetail;
import com.citcc.business.bean.CdzAppUser;
import com.citcc.business.bean.dto.CdzAmountDetailCon;
import com.citcc.business.service.CdzAmountDetailService;
import com.citcc.common.annotation.Log;
import com.citcc.common.base.AjaxResult;
import com.citcc.common.enums.BusinessType;
import com.citcc.common.page.TableDataInfo;
import com.citcc.framework.web.base.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/amountDetail")
public class CdzAmountDetailController extends BaseController {

    private String prefix = "business/amountDetail";

    @Autowired
    private CdzAmountDetailService cdzAmountDetailService;

    @RequiresPermissions("business:amountDetail:view")
    @GetMapping("/main")
    public String vehicle(){
        return prefix + "/main";
    }

    /**
     * 冻结记录
     * @param con
     * @return
     */
    @RequiresPermissions("business:amountDetail:list")
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(CdzAmountDetailCon con){
        startPage();
        List<CdzAmountDetail> list=cdzAmountDetailService.getFreezeAll(con);
        return getDataTable(list);
    }

    /**
     * 删除冻结记录
     */
    @RequiresPermissions("business:amountDetail:remove")
    @Log(title = "冻结管理", businessType = BusinessType.UPDATE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String id)
    {
        try
        {
            int count=cdzAmountDetailService.delete(id);
            return toAjax(count);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
    }

}
